<?php

namespace App\Http\Controllers\Mini\Shop;

use App\Http\Controllers\Controller;
use App\Models\Favorite;
use App\Services\UserService;
use Illuminate\Http\Request;

/**
 * Class StatisticsController
 * @package App\Http\Controllers\Mini\Shop
 * 2021/3/19 - 15:55
 * Administrator
 * 统计控制器
 */
class StatisticsController extends Controller
{
    /**
     * 2021/3/19--15:55
     * @author:董宗澳
     * @email:2453611300
     * @wechat:DZA74941
     * @QQ:2453611300
     * @web:www.quzha.net
     * @method:UserStatistics
     * @effect:用户数据统计
     */
    public function UserStatistics()
    {
        $userService = new UserService();
        $user_info = $userService->getUserInfo();
        $fav_model = new Favorite();
        $fav_num = $fav_model->where(['user_id' => $user_info['id'], 'is_type' => 0])->get()->count();
        $data = [
            'favorites' => $fav_num,
            'integral' => $user_info['integral'],
            'login_day' => 10
        ];
        return $this->format($data);
    }
}
